package com.eazy.lkv2.web.controller.comment;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.eazy.lkv2.web.controller.BaseController;
import com.eazy.lkv2.web.entity.Comment;
import com.eazy.lkv2.web.service.comment.CommentService;


/**
 * @author jzx
 * @date 2016.5.25
 * @desc 评论管理 
 */
@Controller
@RequestMapping("/comment")
public class CommentController extends BaseController<Comment,Integer> {

	@Autowired
	private CommentService commentService;
	
	/**
	 * 虽然做了评论管理，可以反馈或者改进系统but你说了我也不会改→_→怪我咯
	 */
	@RequestMapping(value = "index" , method = RequestMethod.GET)
	public ModelAndView index() {
		addObject("data", commentService.select());
		return getSuccess("comment/comment-list");
	}
	
	/**
	 * 添加评论管理
	 * @param comment
	 */
	@RequestMapping(value = "addComment" , method = RequestMethod.POST)
	public void addComment(Comment comment) {
		comment.setuId(getCurrentUser().getId());
		renderResult(create(comment) > 1);
	}
	
	
	/**
	 * 跳转到评论添加页面
	 */
	@RequestMapping(value = "toAddComment" , method = RequestMethod.GET)
	public ModelAndView toAddComment() {
		return new ModelAndView("comment/comment-add");
	}
}
